<?php

namespace App\Admin\Controllers;

use App\Admin\Repositories\AbductionFilm;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;

class AbductionFilmController extends AdminController
{
    protected $title = '影片';
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new AbductionFilm(), function (Grid $grid) {
            $grid->actions(function (Grid\Displayers\Actions $actions) {
//                $actions->disableDelete();
//                $actions->disableEdit();
                $actions->disableQuickEdit();
                $actions->disableView();
            });
            $grid->column('film_id','ID')->sortable();
            $grid->column('film_image')->image('',100,100);
            $grid->column('film_title');
            $grid->column('film_url');
            $grid->column('film_sort')->editable()->sortable();
            $grid->column('created_at');
            $grid->column('updated_at')->sortable();
            $grid->column('status')->switch('#333');
            $grid->column('is_top','是否置顶')->switch('#333');

            $grid->filter(function (Grid\Filter $filter) {
                $filter->equal('film_id');

            });
        });
    }


    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new AbductionFilm(), function (Form $form) {
            $form->display('film_id','ID');
            $form->image('film_image','图片')->required();
            $form->text('film_title','标题')->required();
            $form->url('film_url','链接')->required();
            $form->number('film_sort','排序')->required();
            $form->switch('is_top','是否置顶');
            $form->saved(function (Form $form) {
                return $form->response()->success('保存成功')->redirect('abduction_film');
            });
            $form->disableHeader();//去掉上面的
            $form->footer(function ($footer) {

                // 去掉`重置`按钮
                //$footer->disableReset();

                // 去掉`提交`按钮
                //$footer->disableSubmit();

                // 去掉`查看`checkbox
                $footer->disableViewCheck();

                // 去掉`继续编辑`checkbox
                $footer->disableEditingCheck();

                // 去掉`继续创建`checkbox
                $footer->disableCreatingCheck();
            });
            $form->display('created_at');
            $form->display('updated_at');
        });
    }
}
